package com.niuke;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * 33. 评论转换输出
 */
public class NiukeMoni33 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split(",");

        // hello,2,ok,0,bye,0,test,0,one,1,two,1,a,0
        int n = 0;
        List<Integer> subSize = new ArrayList<>();
        List<List<String>> result = new ArrayList<>();
        for (int i = 0; i < input.length; i++) {
            List<String> item = null;
            if (result.size() > n) {
                item = result.get(n);
            }
            if (item == null) {
                item = new ArrayList<>();
                result.add(item);
            }

            item.add(input[i]);

            if (subSize.size() > 0) {
                List<Integer> newSubSize = new ArrayList<>();
                for (int j = 0; j < subSize.size(); j++) {
                    if (j != 0) {
                        i++;
                        item.add(input[i]);
                    }
                    int tempSize = subSize.get(j);
                    for (int k = 0; k < tempSize; k++) {
                        i++;
                        if (k == 0) {
                            int subS = Integer.parseInt(input[i]);
                            if (subS > 0) {
                                newSubSize.add(subS);
                            }
                        } else {
                            item.add(input[i]);
                            i++;
                            int subS = Integer.parseInt(input[i]);
                            if (subS > 0) {
                                newSubSize.add(subS);
                            }
                        }
                    }
                }

                subSize.clear();
                subSize.addAll(newSubSize);
                if (subSize.size() == 0) {
                    n = 0;
                } else {
                    n++;
                }
            } else {
                i++;
                int subS = Integer.parseInt(input[i]);
                if (subS > 0) {
                    subSize.add(subS);
                    n++;
                }
            }

        }

        System.out.println(result.size());

        for (int i = 0; i < result.size(); i++) {
            System.out.println(Arrays.toString(result.get(i).toArray()));
        }

    }

}
